<script>
{if $rs.product_class_id}
$().ready(function(){
	getParentProductClass('',{$rs.product_class_id});
	sumBag();
})


function sumBag(){
	if($dom.find("#dozen").length<=0) return;
	var c = parseInt($dom.find("#capability").val());
	var d = parseInt($dom.find("#dozen").val()); 
	if(isNaN(c)) c = 0;
	if(isNaN(d)) d = 0;
	if(c/d=='Infinity'){
		$("#p_s_3").val('');
		return;
	}
	var bag = c/d;
	if(isNaN(bag) || bag==0) bag = '';  
	$dom.find("#p_s_3").val(bag);  
}
{/if}

{if C('PRODUCT_COLOR')==1}
function checkColor(obj){
	if(obj.checked!=true){  
		$.get(APP+'/Ajax/checkProdcutColor/product/{$rs.id}/color/'+obj.value,function(data){
			if(data>0){
				obj.checked = true;
				alert('存在未销售库存，修改失败！')
			}
		})
	}
}
{/if}
{if C('PRODUCT_SIZE')==1}
function checkSize(obj){
	if(obj.checked!=true){ 
		$.get(APP+'/Ajax/checkProdcutSize/product/{$rs.id}/size/'+obj.value,function(data){
			if(data>0){
				obj.checked = true;
				alert('存在未销售库存，修改失败！')
			}
		})
	}
}
{/if}
</script>
<form action="{'Product/update'|U}" method="POST" name="Basic_addProductClass" onsubmit="return false">
{wz action="save,list,reset"}
  <input type="hidden" name="id" value="{$rs.id}">
  <input type="hidden" name="lock_version" id="lock_version" value="{$rs.lock_version}">
  <input type="hidden" name="file_tocken" value="{$file_tocken}">
<!--  <input type="hidden" name="orders_norms" value="{C("ORDERS_NORMS")}">-->
  <div class="add_box">
  <table cellspacing="0" cellpadding="0" class="add_table">
    <tbody>
    <tr><th colspan="2">{$lang.basic_title}</th></tr>
    <tr>
      <td class="width15">{$lang.product_no}：</td>
      <td class="t_left"><input type="text" name="product_no"  value="{$rs.product_no}" {$is_auto_no} >__*__
      </td>
    </tr>
    <tr>
      <td>{$lang.product_name}：</td>
      <td class="t_left"><input type="text" name="product_name" value="{$rs.product_name}" class="spc_input" >__*__
      </td>
    </tr>
     <tr>
      <td>{$lang.class_name}：</td>
      <td class="t_left">
      <input type="hidden" name="product_class_id" id="product_class_id" value="{$rs.product_class_id}"><input id="product_class_name" value="{$rs.product_id_name}" url="{'/AutoComplete/lastProductClass'|U}" jqac >__*__<span id="parent_info"></span></td>
    </tr>
    {if C('PRODUCT_FACTORY')==1}    
    <tr>
      <td>{$lang.factory_name}：</td>
      <td class="t_left"> 
      <input type="hidden" name="factory_id" id="factory_id" value="{$rs.factory_id}"> 
      {if $rs.factory_readonly}
      {$rs.factory_name}
      {else}
      <input id="factory_name" name="temp[factory_name]" value="{$rs.factory_name}" url="{'/AutoComplete/factory'|U}" jqac>__*__
      {/if}
      </td>
    </tr>
    {/if}
    {if C('PRODUCT_COLOR')==1}
    <tr>
      <td>{$lang.color_name}：</td>
      <td class="t_left">
      {if C('PRODUCT_COLOR')==1}
      {checkbox onclick="checkColor(this)" table="color" key="id" field="color_name" name="color[]" where="to_hide=1" value={$rs.color}}
      {else}
       {checkbox table="color" key="id" field="color_name" name="color[]" where="to_hide=1" value=$rs.color}
      {/if}
    </td></tr>
    {/if}
    {if C('PRODUCT_SIZE')==1}
    <tr>
      <td>{$lang.size_name}：</td>
      <td class="t_left">
      {if C('PRODUCT_SIZE')==1}
      {checkbox onclick="checkSize(this)" table="size" key="id" field="size_name" name="size[]" where="to_hide=1" value=$rs.size}
      {else}
      {checkbox table="size" key="id" field="size_name" name="size[]" where="to_hide=1" value=$rs.size}
      {/if}
      </td>
    </tr>
    {/if}
     {if $show_price_title}
    <tr><th colspan="2">{$lang.price_title}</th></tr>
    {/if}
     {if $show_field.instock_price}
    <tr>
      <td>{$lang.instock_price}：</td>
      <td class="t_left">
      <input type="text" name="instock_price" value="{$rs.edml_instock_price|dml}" class="spc_input">（{$cur.in}）</td>
    </tr>
    {/if}
    {if C('MULTI_CLIENT')}
     {if $show_field.wholesale_price}
     <tr>
      <td>{$lang.wholesale_price}：</td>
      <td class="t_left">
      <input type="text" name="wholesale_price" value="{$rs.edml_wholesale_price|dml}" class="spc_input">（{$cur.out}）</td>
    </tr>
    {/if}
     {if $show_field.retail_price}
     <tr>
      <td>{$lang.retail_price}：</td>
      <td class="t_left">
      <input type="text" name="retail_price" value="{$rs.edml_retail_price|dml}" class="spc_input">（{$cur.out}）</td>
    </tr>
    {/if}
     {if $show_field.sale_price}
    <tr>
      <td>{$lang.other_price}：</td>
      <td class="t_left">
      <input type="text" name="sale_price" value="{$rs.edml_sale_price|dml}" class="spc_input">（{$cur.out}）</td>
    </tr>
   {/if}
    {else}
     {if $show_field.sale_price}
     <tr>
      <td>{$lang.sale_price}：</td>
      <td class="t_left">
      <input type="text" name="sale_price" value="{$rs.edml_sale_price|dml}" class="spc_input">（{$cur.out}）</td>
    </tr>
    {/if}
    {/if}
     {if $show_field.instock_price}
   <tr>
      <td>{$lang.avg_price}：</td>
      <td class="t_left">
      {foreach item=item key=key from=$rs.price.avg}
      {if $item>0}{$key}：{$item|dml:true}；{/if}
      {/foreach}
      </td>
    </tr>
    <tr>
      <td>{$lang.last_price}：</td>
      <td class="t_left">
      {foreach item=item key=key from=$rs.price.last}
      {if $item>0}{$key}：{$item|dml:true}；{/if}
      {/foreach}
      </td>
    </tr>
    {/if}
    <tr><th colspan="2">{$lang.propre_title}</th></tr>
        
{if C("storage_format")>1}    
<tr>
<td>{$lang.storage_1}：</td>
<td class="t_left"><input name="capability" id="capability" type="text" value="{$rs.capability}" onkeyup="sumBag()" class="spc_input"/>__*__
</td>
</tr>
{/if}
{if C("storage_format")==3}
<tr>
<td>{$lang.dozen}：</td>
<td class="t_left"><input name="dozen" id="dozen" type="text" value="{$rs.dozen}" onkeyup="sumBag()" class="spc_input"/>__*__
</td>
</tr>
<tr>
<td>{$lang.storage_2}：</td>
<td class="t_left"><input type="text" name="p_s_3" id="p_s_3" value="" readonly class="spc_input"></td>
</tr>
{/if}
<tr>
<td>{$lang.cube}：</td>
<td class="t_left">
{$lang.long}<input name="cube_long" id="cube_long" type="text" onkeyup="getToTtalCube(this);"  value="{if $rs.dml_cube_long>0}{$rs.dml_cube_long}{/if}"  class="spc_input" style="width:80px!important;"/>M *
{$lang.wide}<input name="cube_wide" id="cube_wide" type="text" onkeyup="getToTtalCube(this);"  value="{if $rs.dml_cube_wide>0}{$rs.dml_cube_wide}{/if}"  class="spc_input" style="width:80px!important;"/>M *
{$lang.high}<input name="cube_high" id="cube_high" type="text" onkeyup="getToTtalCube(this);"  value="{if $rs.dml_cube_high>0}{$rs.dml_cube_high}{/if}"   class="spc_input" style="width:80px!important;"/>M
=<input name="cube" id="cube" type="text" readonly    value="{$rs.dml_cube}" class="spc_input readonly" style="width:80px!important;"/>M3

</td>
</tr>
<tr>
<td>{$lang.weight}：</td>
<td class="t_left"><input name="weight" id="weight" type="text" value="{if $rs.dml_weight>0}{$rs.dml_weight}{/if}"  class="spc_input"/> KG
</td>
</tr>


{if C('PRODUCT_COLOR')==1 && C('PRODUCT_SIZE')==1}
<tr>
<td>{$lang.fit}：</td>
<td class="t_left">
<div class="product_width">{html_fit class="fit" value="`$rs.fit`"}</div>
</td>
</tr>
{/if}
<tr>
<td>{$lang.product_pics}：</td>
<td class="t_left">
{upload tocken=$file_tocken sid=$sid type=1}
</td>
</tr> 
{if $rs.pics}
<tr>
<td>{$lang.product_pics}：</td>
<td class="t_left">{showFiles from=$rs.pics delete=true}
</td>
</tr>
{/if}

{if $smarty.const.LANG_SET=='fr'}
{assign var="properties_name" value="properties_name_fr"}
{assign var="pv_name" value="pv_name_fr"}
{else}
{assign var="properties_name" value="properties_name"}
{assign var="pv_name" value="pv_name"}
{/if}
    {foreach key=key item=item from=$rs.detail}
    <input type="hidden" name="product_detail[{$key}][id]" value="{$item.id}">
    <input type="hidden" name="product_detail[{$key}][properties_id]" value="{$item.properties_id}">
    <tr>
      <td>{$item.$properties_name}：</td>
      <td class="t_left">
      {if $item.properties_type==1}
      <input type="text" name="product_detail[{$key}][value]" value="{$item.value}" class="spc_input">
      {elseif $item.properties_type==2}
      {select combobox="1" name="product_detail[`$key`][value]" value="`$item.value`" table="properties_value" key="id" field=$pv_name where="id in(select properties_value_id from properties_info where properties_id=`$item.properties_id`) and to_hide=1" empty=true}
      {elseif $item.properties_type==3}
      {checkbox name="product_detail[`$key`][value][]" value="`$item.value`" table="properties_value" key="id" field=$pv_name where="id in(select properties_value_id from properties_info where properties_id=`$item.properties_id`) and to_hide=1"}
      {/if}
      </td>
    </tr>
    {/foreach}
     <tr>
      <td valign="top">{$lang.comments}：</td>
      <td class="t_left"><textarea name="comments">{$rs.edit_comments}</textarea>
      </td>
    </tr>
    </tbody>
  </table> 
  </div>
</form>
